home *** CD-ROM | disk | FTP | other *** search
- /*
- File: RegisteredObjects.h
-
- Contains: Various classes for keeping track of instances of a certain class and making
- sure the test app keeps its windows updated.
-
- Copyright: © 1991-1994 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #ifndef __REGISTEREDOBJECTS__
- #define __REGISTEREDOBJECTS__
-
- #ifndef __LIBRARYMANAGERCLASSES__
- #include <LibraryManagerClasses.h>
- #endif
-
- class TInspector;
-
- class TUpdateInspectorOp;
- class TRegisteredObjects;
- class TRegisteredObjectsWindow;
-
- /**********************************************************************
- ** class TUpdateInspectorOp
- ***********************************************************************/
-
- enum UpdateState {kScheduled, kExecuting, kFinished};
- enum UpdateCommand {kNone, kNew, kUpdate, kDelete, kDeleteAndDie};
-
- #define kTUpdateInspectorOpID "slm:supp$upio,1.2"
-
- class TUpdateInspectorOp : public TOperation
- {
- public:
- _CDECL TUpdateInspectorOp();
- virtual ~_CDECL TUpdateInspectorOp();
-
- virtual void _CDECL Process();
-
- // New Methods
-
- UpdateState GetState() const;
- void SetState(UpdateState);
- UpdateCommand GetCommand() const;
- void SetCommand(UpdateCommand);
- TMacSemaphore* GetSemaphore();
-
- private:
- UpdateState fState;
- UpdateCommand fCommand;
- TMacSemaphore fSemaphore;
- };
-
- /* -----------------------------------------------------------------
- inline methods
- ----------------------------------------------------------------- */
-
- inline UpdateState TUpdateInspectorOp::GetState() const
- {
- return fState;
- }
-
- inline void TUpdateInspectorOp::SetState(UpdateState theState)
- {
- fState = theState;
- }
-
- inline UpdateCommand TUpdateInspectorOp::GetCommand() const
- {
- return fCommand;
- }
-
- inline void TUpdateInspectorOp::SetCommand(UpdateCommand theCommand)
- {
- fCommand = theCommand;
- }
-
- inline TMacSemaphore* TUpdateInspectorOp::GetSemaphore()
- {
- return &fSemaphore;
- }
-
- /**********************************************************************
- ** class TRegisteredObjects
- ***********************************************************************/
-
- #define kTRegisteredObjectsID "slm:supp$rego,1.2"
-
- class TRegisteredObjects : public TDynamic
- {
- public:
- _CDECL TRegisteredObjects(char *theName, TInspector** theInspector);
- virtual ~_CDECL TRegisteredObjects();
-
- virtual void _CDECL Register(TDynamic *theObj);
- virtual void _CDECL UnRegister(TDynamic *theObj);
- virtual void _CDECL RegisterWithInspector();
-
- TInspector* GetInspector() const;
- unsigned long GetCount() const;
- TMacSemaphore* GetSemaphore();
- char* GetClassName() const;
- void SetRegisteredObjectsWindow(TRegisteredObjectsWindow*);
- TRegisteredObjectsWindow* GetRegisteredObjectsWindow() const;
-
- virtual TDynamic* _CDECL operator[](size_t);
-
- private:
- TInspector** fInspector; /* ptr to the TClassCatalogs TInspector* field */
- TLinkedList* fObjects; /* instances of this type */
- char* fClassName;
- TRegisteredObjectsWindow* fRegisteredObjectsWindow;
- TUpdateInspectorOp fUpdateInspectorOp; /* op for telling the Inspector about changes
- to the list */
- TMacSemaphore fSemaphore;
- };
-
- /* -----------------------------------------------------------------
- Inline methods
- ----------------------------------------------------------------- */
-
- inline TInspector* TRegisteredObjects::GetInspector() const
- {
- return *fInspector;
- }
-
- inline unsigned long TRegisteredObjects::GetCount() const
- {
- return fObjects->Count();
- }
-
- inline TMacSemaphore* TRegisteredObjects::GetSemaphore()
- {
- return &fSemaphore;
- }
-
- inline char* TRegisteredObjects::GetClassName() const
- {
- return fClassName;
- }
-
- inline void TRegisteredObjects::SetRegisteredObjectsWindow(TRegisteredObjectsWindow *theWindow)
- {
- fRegisteredObjectsWindow = theWindow;
- }
-
- inline TRegisteredObjectsWindow* TRegisteredObjects::GetRegisteredObjectsWindow() const
- {
- return fRegisteredObjectsWindow;
- }
-
- #endif
-